//
//  ST_RechargeTipsCell.swift
//  btvideo
//
//  Created by mac on 2020/11/17.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyAttributes
import SwiftyUserDefaults


class ST_RechargeTipsCell: UITableViewCell {

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.contentView.backgroundColor = UIColor.white
    
        
        contentView.addSubview(gray_background_view)
        gray_background_view.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets.init(top: 0, left: 15, bottom: 16, right: 15))
        }
        
        
        gray_background_view.addSubview(label)
        label.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.top.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
//            make.height.equalTo(40)
        }

        gray_background_view.addSubview(btn)
        btn.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.height.equalTo(40)
            make.bottom.equalToSuperview().offset(-5)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate lazy var gray_background_view:UIView = {
       let control = UIView()
        control.backgroundColor = UIColor.init(hex: 0xF5F8FA)
        control.cornerRadius = 15
        return control
    }()
    
    
    fileprivate lazy var label:UILabel = {
       
        let control = UILabel()
        
        control.numberOfLines = 0
        
        return control
    }()
    
    fileprivate lazy var btn:UIButton = {
        
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        
        control.setTitleForAllStates("点击充值金币")
        
        control.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)
        
        control.setTitleColorForAllStates(UIColor.init(hex: 0xFEC207)!)
        
        control.addTarget(self, action: #selector(add_pec_handle), for: UIControl.Event.touchUpInside)
        
        return control
    }()
    
    @objc fileprivate func add_pec_handle(){
        
        ST_MaidWayManager.shared.source = .聊天充币
        
        ST_RechargeViewController.toast()
        
    }
    
    
    var keyString = ""{
        didSet{
            
            
            let normalAttr:[Attribute] = [.font(UIFont.systemFont(ofSize: 14)),.textColor(UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 1))]
            
            let yellowAttr:[Attribute] = [.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium)),.textColor(UIColor.init(hex: 0xFEC207)!)]
            
            
            let attrString = "今日\(Defaults[.PandaWriteKindStr])消息数已用完，充值甜心币就可以继续畅聊了哦！互相喜欢后开启畅聊，当你和对方亲密度达到".withAttributes(normalAttr)
            
            let str0 = keyString.withAttributes(yellowAttr)
            let str1 = "时聊天\(Defaults[.PandaWriteKindStr])。对方的".withAttributes(normalAttr)
            let str2 = "微信号".withAttributes(yellowAttr)
            let str3 = "也会在亲密度达到的同时自动解锁。".withAttributes(normalAttr)
          
            
            attrString.append(str0)
            attrString.append(str1)
            attrString.append(str2)
            attrString.append(str3)
            
            attrString.addAttributes([NSAttributedString.Key.paragraphStyle:NSParagraphStyle.create_line_spacing_paragraph_style(lineSpacing: 2)], range: NSRange(location: 0, length: attrString.length))
            
            
            label.attributedText = attrString
        }
    }
    
//    var send_requre_coin = 0{
//        didSet{
//           
//
//            
//        }
//    }
    
    var message:ST_DTChatMessage! {
        didSet{
          
            
            
            
        }
    }
   
}
